﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace COP.Extensions
{
    public static class XMlExtension
    {
        public static string GetAttributeValue(this XmlNode node, string key)
        {
            return GetAttributeValue(node, key,false);
        }


        public static string GetAttributeValue(this XmlNode node, string key,bool isMandate)
        {
            string val = null;
            try
            {
                val = node.Attributes[key].Value;
            }
            catch (Exception ex)
            {
                if (isMandate)
                    throw new Exception(Constant.Error.AttributeRequired);
            }
            return val;
        }
    }
}
